﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ParsecClient
{
    /// <summary>
    /// Interaction logic for ErrorWindow.xaml
    /// </summary>
    public partial class MessageWindow : Window
    {
        public bool FocusOnLoad = false;
        public bool IsModal = false;
        public MessageWindow(string message, bool isError, bool showCancel, bool focusOnLoad, bool isModal)
        {
            InitializeComponent();
            FocusOnLoad = focusOnLoad;
            IsModal = isModal;
            if (!showCancel)
                btnCancel.Visibility = System.Windows.Visibility.Collapsed;
            txtContent.Text = message;
            if (isError)
                txtContent.Foreground = new SolidColorBrush(Colors.DarkRed);
            else
                txtContent.Foreground = new SolidColorBrush(Colors.Black);
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (IsModal)
                this.DialogResult = true;
            else if (Owner != null)
                Owner.IsEnabled = true;
            this.Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            if (IsModal)
                this.DialogResult = false;
            else if (Owner != null)
                Owner.IsEnabled = true;
            this.Close();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (FocusOnLoad)
                btnOk.Focus();
        }

    }
}
